package com.zzedu.system.service.impl;

import com.zzedu.common.utils.StringUtils;
import com.zzedu.system.domain.UploadFile;
import com.zzedu.system.mapper.UploadFlieMapper;
import com.zzedu.system.service.ISysUploadFileService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * 文件记录管理Service业务层处理
 *
 * @author smarthome
 * @date 2022-05-03
 */
@Service
public class SysUploadFileServiceImpl extends ServiceImpl<UploadFlieMapper, UploadFile> implements ISysUploadFileService {

    @Override
    public Wrapper<UploadFile> buildQuery(UploadFile uploadFile) {
        LambdaQueryWrapper<UploadFile> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.like(StringUtils.isNotBlank(uploadFile.getFileName()), UploadFile::getFileName, uploadFile.getFileName());
        lambdaQueryWrapper.like(StringUtils.isNotBlank(uploadFile.getHttpUrl()), UploadFile::getHttpUrl, uploadFile.getHttpUrl());
        lambdaQueryWrapper.eq(StringUtils.isNotBlank(uploadFile.getFileType()), UploadFile::getFileType, uploadFile.getFileType());
        lambdaQueryWrapper.orderByDesc(UploadFile::getId);
        return lambdaQueryWrapper;
    }
}
